<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Get Cookie Value</title>
  <script>
    function getCookie(cookieName) {
      const cookies = document.cookie.split(';');
      for (let i = 0; i < cookies.length; i++) {
        const cookie = cookies[i].trim();
        // Check if this cookie starts with the name we're looking for
        if (cookie.startsWith(cookieName + '=')) {
          // Return everything after the cookie name and '='
          return decodeURIComponent(cookie.substring(cookieName.length + 1));
        }
      }
      // If cookie not found, return null or handle appropriately
      return null;
    }

    // Example usage:
    document.addEventListener('DOMContentLoaded', function() {
      const myCookieValue = getCookie('exampleCookie');
      if (myCookieValue) {
        console.log('Cookie value:', myCookieValue);
        // You can use myCookieValue in your application as needed
      } else {
        console.log('Cookie not found or empty.');
      }
    });
  </script>
</head>
<body>
  <!-- This is just a placeholder body for demonstration -->
  <h1>Getting Cookie Value Example</h1>
</body>
</html>
